import Vue from 'vue'
import CryptoJS from './crypto-js'
import setting from './setting'
var KEY = CryptoJS.enc.Utf8.parse(setting.getAesKey()); //十六位十六进制数作为秘钥
var IV = CryptoJS.enc.Utf8.parse(setting.getAesIv());//十六位十六进制数作为秘钥偏移量


const aes = {}
const PORT1 = 'auhtority'
// POST请求方式
aes.decrypt = function(word){
	var decrypted = CryptoJS.AES.decrypt(word, KEY,
		{
			iv: IV,
			padding: CryptoJS.pad.Pkcs7
		});
	return decrypted.toString(CryptoJS.enc.Utf8);
}
aes.encrypt = function(word){
	let encrypted = CryptoJS.AES.encrypt(word, KEY,
		{
			iv: IV,
			mode: CryptoJS.mode.CBC,
			padding: CryptoJS.pad.Pkcs7
		});
	return encrypted.toString();
}

export default aes